package com.wzz.seckillone.controller;


import com.alibaba.fastjson.JSON;
import com.wzz.seckillone.common.PageInfoDTO;
import com.wzz.seckillone.service.SeckillGoodsService;
import com.wzz.seckillone.common.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author jobob
 * @since 2021-11-08
 */
@Controller
@RequestMapping("/secKillGoods")
public class SecKillGoodsController {

    @Autowired
    private SeckillGoodsService seckillGoodsService;


    @GetMapping("/toSeckillGoodsWh")
    public String toSeckillGoodsWh(){
        return "seckillWh/seckillList";
    }
    /**
     * @Method
     * @Author wzz
     * @Version  1.0
     * @Description 分页查询秒杀商品数据
     * @param
     * @Return
     * @Exception
     * @Date 2022/3/15 23:06
     */
    @GetMapping("/getSeckillGoodsList")
    public String getSeckillGoodsList(PageInfoDTO info,String keyWord){
        AjaxResult result = new AjaxResult();
        try{
            result.setSuccess(true).setData(seckillGoodsService.getSeckillGoodsList(info,keyWord));
        }catch(Exception e){
            result.setSuccess(false).setMessage(e.getMessage());
        }
        return JSON.toJSONString(result);
    }

}
